package net.lcheng.shop.Controller;

import com.alibaba.fastjson.JSON;
import net.lcheng.model.BaseAreas;
import net.lcheng.service.BaseAreasService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by zwr on 2016/7/2 0002.
 */
@RestController
public class AjaxAreaUtilsController {
    @Autowired
    private BaseAreasService baseAreasService;
    /**
     * 异步获取省列表列表
     * @param parentCode
     * @return
     */
    @RequestMapping(value = "/ajax/get_area",method = RequestMethod.GET)
    @ResponseBody
    public String getParentCodeList(@RequestParam String parentCode) {
        if (parentCode.equals("null")){
            List<BaseAreas> list = baseAreasService.getParentCodeByAreaName("");
            return JSON.toJSONString(list);
        } else {
            List<BaseAreas> list = baseAreasService.getParentCodeByAreaName(parentCode);
            return JSON.toJSONString(list);
        }
    }
}
